﻿package code {
	
	public class Modifier {
		private var stat:String;
		private var duration:int;
		private var amount:int;
		
		public function get Stat():String{ return stat; }
		
		public function Modifier(stat:String, duration:int, amount:int) {
			this.stat = stat;
			this.duration = duration;
			this.amount = amount;
		}
		
		// modifies the player based on what effect is in play.  Returns if the modifier is still in effect.
		public function modify(p:Player):Boolean{
			if(stat == "attack"){
				p.TempAttack = amount;
			}
			else if(stat == "defense"){
				p.TempDefense = amount;
			}
			else if(stat == "hp"){
				p.Hp -= amount;
			}
			
			trace("Stat modified");
			
			duration--;
			
			if(duration <= 0)
				return true;
			else
				return false;
		}

	}
	
}
